1. Field of the Invention
The present invention relates to an image processing technique for a color image, and more particularly to an image processing method for recognizing a point positioned at the boundary between regions having different colors, a program for setting the function for executing the method in a computer, and an image processing device having the function for executing the method.
2. Description of the Background Art
When an object to be measured is to be detected by conventional monochrome gray image processing, an edge extracting process is performed in many cases. Furthermore, in order to perform the process with high precision, it is proposed by the applicant recently that angle data showing a density gradient direction (referred to as the “edge code” hereinafter) is found with respect to a point constituting an edge in an image (referred to as the “edge point” hereinafter) based on a density difference in each of a horizontal direction and a vertical direction.
For example, when an object having a predetermined outline configuration is to be extracted, a reference distribution pattern of the edge code is registered using a model image of the object previously and a region in which the edge code is distributed in a state similar to the reference distribution pattern is extracted in the image of the processing object (refer to, for example, Japanese Laid-Open Patent Publication No. 2002-230549: patent document 1). In addition, when a linear object is to be detected, after the edge point constituting the outline of the object has been specified using the edge code, a line is set along a direction perpendicular to the edge code (refer to, for example, Japanese Laid-Open Patent Publication No. 2004-133811: patent document 2).
Meanwhile, since the color image is provided such that image data of R, G and B are combined in general, when the process using the edge code is performed, it is necessary to convert color image data to monochrome gray image data.
However, in order to reflect the direction of the color change in the edge code correctly, since it is necessary to perform a converting process by which various kinds of colors are expressed by different densities, the calculation for the conversion becomes complicated and it takes time to perform the process.
Thus, it is necessary to consider a method for applying a calculating method of the edge code in the monochrome image to the color image.
While the edge code in the monochrome gray image shows the direction of the density change (density gradient direction), an edge is generated due to a largely change in color in the color image, so that it is believed that the direction of the color change is to be the edge code. That is, in the monochrome gray image processing, the amount of density change is found in the horizontal direction and the vertical direction and the edge code is calculated from the change amount, while in the color image processing, it is considered that amounts of color change (color difference) in the horizontal direction and the vertical direction are to be found instead of the amount of density change.
Here, a method for calculating the color difference will be described using a concrete example.
When the color is expressed as parameters of three primary colors R, G and B (referred to as the “color parameters” hereinafter), for example, each color is plotted to one point in Euclidean space (referred to as the “color space” hereinafter) having an axis of the color parameter. This color difference is expressed as a distance between two points in the color space.
For example, as shown in FIG. 9, in an image in which a X-Y coordinate system in which the horizontal direction is an X axis and the vertical direction is a Y axis, when it is assumed that image data of two adjacent pixels are (Ra, Ga, Ba) and (Rb, Gb, Bb), these colors are plotted to points A and B corresponding to the image data in the color space. In this case, the color difference CD between the pixels is found by the following formula [1].[Formula 1]CD=√{square root over ((Ra−Rb)2+(Ga−Gb)2+(Ba−Bb)2)}{square root over ((Ra−Rb)2+(Ga−Gb)2+(Ba−Bb)2)}{square root over ((Ra−Rb)2+(Ga−Gb)2+(Ba−Bb)2)}  [1]
Thus, it seems only necessary to find the color difference in the X and Y directions using the formula [1] instead of the density difference in the color image. However, since the value found by the formula [1] is always a positive value, the calculated edge code does not reflect the color change correctly.
The above problem will be described with reference to FIGS. 10 and 11. FIG. 10 shows a coordinate system for specifying the direction of the color change.
According to the conventional monochrome gray image processing, since the density difference having a positive or a negative value can be provided in both X and Y directions, the direction of the density change generated based on the edge point can be correctly expressed by arranging the edge point to the origin “O” of the coordinate system and setting a resultant vector of vectors showing the density difference in both X and Y directions. That is, the edge code found from the monochrome gray image is considered to be distributed all quadrants in the X-Y coordinate system in FIG. 10. Meanwhile, since the color difference in the case of the color image becomes 0 or a positive value, the edge code is limited to the range of the first quadrant.
FIG. 11 shows directions of the color change generated based on the pixel positioned in the center in a focal region (5 pixels×5 pixels) in which two kinds of colors are shown.
In the illustrated example, according to images G1 and G2, although the positions of two color regions (a gray region and a white region) are reversed, the position and inclination of the boundary is the same. Since there is no positive/negative relation between the colors, it is considered that the direction of the color change in the images G1 and G2 is the same and the color is changed along the direction from the lower left to the upper right in each image.
Meanwhile, according to an image G3, since the inclination of the boundary between color regions is different from that of the images G1 and G2, the direction of the color change is also different from that of the images G1 and G2.
However, according to the image G3, since only the same color difference value as that of the images G1 and G2 is provided, the edge code that reflects the difference in direction of the color change cannot be provided.